Seats.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Seats.aspx.cs" Inherits="Seats" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .checkboxG
        {
            position: relative;
        }
        .checkboxG input
        {
            position: absolute;
            left: 2px;
            top: 3px;
            margin: 0;
            z-index: 0;
        }
        .checkboxG label
        {
            display: block;
            position: relative;
            z-index: 1;
            font-size: 1.3em;
            padding-right: 1em;
            line-height: 1;
            padding: .5em 0 .5em 30px;
            margin: 0 0 .3em;
            cursor: hand;
        }
        .checkboxG label
        {
            background: url(images/SeatG.gif) no-repeat;
        }
        .checkboxY
        {
            position: relative;
        }
        .checkboxY input
        {
            position: absolute;
            left: 2px;
            top: 3px;
            margin: 0;
            z-index: 0;
        }
        .checkboxY label
        {
            display: block;
            position: relative;
            z-index: 1;
            font-size: 1.3em;
            padding-right: 1em;
            line-height: 1;
            padding: .5em 0 .5em 30px;
            margin: 0 0 .3em;
            cursor: hand;
        }
        .checkboxY label
        {
            background: url(images/SeatY.gif) no-repeat;
        }
        .checkboxR
        {
            position: relative;
        }
        .checkboxR input
        {
            position: absolute;
            left: 2px;
            top: 3px;
            margin: 0;
            z-index: 0;
        }
        .checkboxR label
        {
            display: block;
            position: relative;
            z-index: 1;
            font-size: 1.3em;
            padding-right: 1em;
            line-height: 1;
            padding: .5em 0 .5em 30px;
            margin: 0 0 .3em;
            cursor: pointer;
        }
        .checkboxR label
        {
            background: url(images/SeatR.gif) no-repeat;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
        <tr>
             <td>
                 <input type="text" runat="server" id="hdnSeats" style="width: 500px" />
                 <asp:Panel ID="Panel2" runat="server" Visible="true" BorderWidth="2" BorderColor="Black">
                 </asp:Panel>
           </td>
        </tr>
    </table>
    </div>
    </form>
</body>
</html>



Seats.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class Seats : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        bindSeats();
    }
    private void bindSeats()
    {
        int l_availSeats = Convert.ToInt32(10);
        int l_totSeats = Convert.ToInt32(25);

        Panel2.Controls.Clear();
        int rowDefn = 6;
        int rowsCount = l_totSeats;
        //int colsCount = 10;
        int tmp = l_totSeats / rowDefn;
        int tmp1 = l_totSeats % rowDefn;
        int Seatnum = 1;
        Table tbl = new Table();
        tbl.Width = Unit.Pixel(10);
        tbl.Height = Unit.Pixel(10);
        tbl.ID = "Table1";
        Panel2.Controls.Add(tbl);
        string strCtrl = string.Empty;
        string strCheckbox = string.Empty;
        int iSeatCnt = 0;
        for (int i = 0; i < tmp; i++)
        {
            TableRow row = new TableRow();
            for (int j = 0; j < rowDefn; j++)
            {
                iSeatCnt = iSeatCnt + 1;
                TableCell cell = new TableCell();
                string btnstri = (i + 1).ToString() + "_" + (j + 1).ToString();

                if (l_availSeats > 0 && l_availSeats < iSeatCnt)
                {
                    strCtrl = "<div id='div" + btnstri + "' class='checkboxY'><input disabled='disabled' id='chk" + btnstri + "' type='checkbox' onclick='chkThis(this)' /><label class='' for='chk" + btnstri + "'>&nbsp;</label></div>";
                }
                else
                {
                    strCtrl = "<div id='div" + btnstri + "' class='checkboxG'><input id='chk" + btnstri + "' type='checkbox' onclick='chkThis(this)' /><label class='' for='chk" + btnstri + "'>&nbsp;</label></div>";
                }
                HtmlGenericControl htmCtrl = new HtmlGenericControl("span");
                htmCtrl.InnerHtml = strCtrl;
                cell.Controls.Add(htmCtrl);
                row.Cells.Add(cell);
                Seatnum++;
            }
            tbl.Rows.Add(row);
        }

        if (tmp1 > 0)
        {
            for (int i = 0; i < 1; i++)
            {
                TableRow row = new TableRow();
                for (int j = 0; j < tmp1; j++)
                {
                    iSeatCnt = iSeatCnt + 1;
                    TableCell cell = new TableCell();
                    string btnstri = (i + 1).ToString() + "_" + (j + 1).ToString();
                    if (l_availSeats > 0 && l_availSeats < iSeatCnt)
                    {
                        strCtrl = "<div id='div" + btnstri + "' class='checkboxR'><input disabled='disabled' id='chk" + btnstri + "' type='checkbox' onclick='chkThis(this)' /><label class='' for='chk" + btnstri + "'>&nbsp;</label></div>";
                    }
                    else
                    {
                        strCtrl = "<div id='div" + btnstri + "' class='checkboxG'><input id='chk" + btnstri + "' type='checkbox' onclick='chkThis(this)' /><label class='' for='chk" + btnstri + "'>&nbsp;</label></div>";
                    }

                    HtmlGenericControl htmCtrl = new HtmlGenericControl("span");
                    htmCtrl.InnerHtml = strCtrl;
                    cell.Controls.Add(htmCtrl);
                    Seatnum++;
                    row.Cells.Add(cell);
                }
                tbl.Rows.Add(row);
            }
        }


    }
}
